//package cn.itcast.gateway.config;
//
//import org.springframework.boot.web.servlet.filter.OrderedFilter;
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.cloud.gateway.filter.GlobalFilter;
//import org.springframework.core.annotation.Order;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.http.server.reactive.ServerHttpResponse;
//import org.springframework.stereotype.Component;
//import org.springframework.util.MultiValueMap;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
///**
// * @Author xph
// * @Date 2022/8/9 19:10
// * @Description: 自定义全局过滤器
// */
//
//@Order(-1)
//@Component
//public class AuthorizeFilter implements GlobalFilter {
//
//    /**
//     * 自定义放行逻辑
//     *
//     * @param exchange
//     * @param chain
//     * @return
//     */
//    @Override
//    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
//        // 1、获取参数
//        MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams();
//        // 2、获取校验参数
//        String authorization = queryParams.getFirst("authorization");
//        // 3、判断是否符合
//        if (authorization.equals("lan")) {
//            // 3.1、放行
//            return chain.filter(exchange);
//        }
//        // 4、设置状态码
//        ServerHttpResponse response = exchange.getResponse();
//        response.setStatusCode(HttpStatus.UNAUTHORIZED);
//        // 5、拦截
//        return response.setComplete();
//    }
//}
